<script src="store/index.js">
    methods: {
        showMsgFromChild: function(data){
            // 调用
            this.$store.commit('edit');
            console.log(this.$store.state.name);
        }
    }
    //单个值提交
    methods:{
        showMsgFromChild:function(){
            this.$store.commit('edit',"xiaocang");
            console.log(this.$store.name);
        }
    }
    // 接收挂载的参数
    mutations:{
        edit(state,payload){
            state.name="jack"
            console.log(payload);
        }
    }
    //多个参数提交，就在一个对象中
    methods: {
        showMsgFromChild: function(){
            this.$store.commit('edit',{age:18,name:"xiaocang"});
            console.log(this.$store.name);
        }
    }
    // 接收挂载的参数
    mutations:{
        edit(state,payload){
            state.name="jack"
            console.log(payload.age+"--"+payload.name);
        }
    }
    // 多个参数提交，放在一个对象中
    methods: {
        showMsgFromChild: function(){
            this.$store.commit({
                type:"edit",
                payload:{
                    age:18,
                    name:"xiaobo"
                }
            });
        console.log(this.$store.state.name);
        }
    }
    // 接收挂载的参数
    mutations:{
        edit(state,payload){
            state.name="jack"
            console.log(payload.payload.name+"--"+payload.payload.age);
        }
    }
    //Vue.set为某个对象设置成员的值，若不存在则新增
    mutations:{
        edit(state){
            /* name属性已经存在，修改name的值 */
            Vue.set(state,"name","xiaoxiao");
            /* age属性不存在，则新增age属性，值为18 */
            Vue.set(state,"age",18);
        }
    }

    //Vue.delete删除成员
    mutations:{
        edit(state){
            /* name属性已经存在，修改name的值 */
            Vue.set(state,"name","xiaoxiao");
            /* age属性不存在，则新增age属性，值为18 */
            Vue.set(state,"age",18);
            /* 删除age属性，再获取age的值就是undefined */
            Vue.delete(state,"age");
        }
    }

    //Getters
    methods: {
        showMsgFromChild: function(){
            console.log(this.$store.getters.fullInfo);
        }
    }
</script>